<?php

/**
 * ExtTemplateBase class file
 *
 * @author TrueSoftware B.V. (The Netherlands)
 * @link http://www.ext4yii.com
 * @copyright Copyright 2007-2010 TrueSoftwareB.V. all rights reserved.
 * @license http://www.ext4yii.com/license/
 *          EVALUATION VERSION - NOT FOR COMMERCIAL USE OR DISTRIBUTION.
 * @version 0.7.2
 */
abstract class ExtTemplateBase extends ExtWidget
{

    private $_template = null;

    public function parseNode(ExtHTMLParserNode $node, ExtASTWalker $astwalker)
    {
        /*
         * no need to parse the parent of a Template
         * parent::parseNode($node, $astwalker);
         */
        $body = $node->findPropertyByName('body');
        if (!is_null($body))
        {
            $result = array();
            $lines = explode("\n", trim($body->innertext));
            foreach ($lines as $line)
                $result[] = trim($this->parseValue(trim($line),null));
            $body->innertext = '';
            $body->shiftUp();
            $this->_template = trim(implode(',', $result));
        }
    }

    public function renderConfig($asobject=true)
    {
        return sprintf('new %s(%s,%s)', $this->getXClass(), $this->_template, parent::renderConfig(false));
    }

}
?>
